package com.leyou.client;

import com.leyou.common.vo.PageResult;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {
    @GetMapping("spu/page")
    PageResult<SpuDTO> querySpuByPage(
            @RequestParam(value = "page",defaultValue = "1")Integer page,
            @RequestParam(value = "rows",defaultValue = "5")Integer rows,
            @RequestParam(value = "key",required = false)String key,
            @RequestParam(value = "saleable",required = false)Boolean saleable
    );

    @GetMapping("category/list")
    List<CategoryDTO> queryCategoryByIds(@RequestParam("cids") List<Long> cids);

    @GetMapping("sku/of/spu")
    List<SkuDTO> querySkuBySpuId(@RequestParam("id")Long spuId);

    @GetMapping("spec/params")
    List<SpecParamDTO> querySpecParams(
            @RequestParam(value = "gid",required = false)Long gid,
            @RequestParam(value = "cid",required = false)Long cid,
            @RequestParam(value = "searching",required = false)Boolean searching
    );

    @GetMapping("spu/detail")
    SpuDetailDTO querySpuDetailById(@RequestParam("id")Long spuId);

    @GetMapping("brand/list")
    List<BrandDTO> queryBrandByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping("spu/{id}")
    SpuDTO querySpuById(@PathVariable("id")Long id);

    @GetMapping("/spec/of/category")
    List<SpecGroupDTO> querySpecsByCid(@RequestParam("id") Long id);

    @GetMapping("brand")
    BrandDTO queryBrandById(@RequestParam("id")Long id);

    @GetMapping("sku/list")
    List<SkuDTO> querySkuByIds(@RequestParam("ids")List<Long> ids);

    @PutMapping("/stock/minus")
    Void minusStock(@RequestBody Map<Long,Integer> cartMap);
}
